package cn.itrip.auth.service.impl;

import cn.itrip.auth.service.SmsService;
import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service("smsService")
public class SmsServiceImpl implements SmsService {

    @Override
    public void send(String to, String templateId, String[] datas) throws Exception{
        CCPRestSmsSDK sdk=new CCPRestSmsSDK();
        sdk.init("app.cloopen.com","8883");
        sdk.setAccount("8a216da868125936016835ca8fd012c0","348210ce67714ea7a806818ac822695b");
        sdk.setAppId("8a216da868125936016835ca901d12c6");
        HashMap result=sdk.sendTemplateSMS(to,templateId,datas);
        if ("000000".equals(result.get("statusCode")))
            System.out.println("短信发送成功！");
        else
            throw new Exception(result.get("stausCode").toString()+":"+result.get("stausMsg").toString());

    }
}
